/*
 * @lc app=leetcode.cn id=771 lang=swift
 *
 * [771] 宝石与石头
 */

// @lc code=start
class Solution {
    func numJewelsInStones(_ jewels: String, _ stones: String) -> Int {
        let jewelsSet = Set(Array(jewels))
        let result = stones.reduce(0) {jewelsCount, stone in
            jewelsSet.contains(stone) ? jewelsCount + 1 : jewelsCount
            
        }
        return result

    }
}
// @lc code=end

